/*
 * @Author: szx
 * @Date: 2022-03-16 15:07:33
 * @LastEditTime: 2022-03-16 15:09:47
 * @Description:
 * @FilePath: \leetcode\剑指offer\06\06.js
 */
/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */
/**
 * @param {ListNode} head
 * @return {number[]}
 */
var reversePrint = function (head) {
    const res = [];
    while (head) {
        res.push(head.val);
        head = head.next;
    }
    return res.reverse();
};

var reversePrint = function (head) {
    const res = [];
    const st = [];
    while (head) {
        st.push(head.val);
        head = head.next;
    }
    while (st.length) {
        res.push(st.pop());
    }
    return res;
};
